package com.bj58.groupbuy.action.service.impl;

import java.util.List;

import com.bj58.groupbuy.action.db.CommonDao;
import com.bj58.groupbuy.action.db.DBConfig;
import com.bj58.groupbuy.action.model.ChinahrSource;
import com.bj58.groupbuy.action.service.ChinahrSourceService;

public class ChinahrSourceServiceImpl implements ChinahrSourceService{

	private CommonDao comDao = new CommonDao();

	@Override
	public List<ChinahrSource> getSource1(String platform) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT * FROM data_dict.m_common_chinahr_source ");
		sql.append(" where platform = '"+platform+"' ");
		sql.append(" and source1 is not null ");
		sql.append(" GROUP BY source1 ");
		
		return comDao.getAllColsByVo(sql.toString(), ChinahrSource.class, DBConfig.db_131_data_bi.getIntType());
	}

	@Override
	public List<ChinahrSource> getSource2(String platform, String source1)
			throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT * FROM data_dict.m_common_chinahr_source ");
		sql.append(" where platform = '"+platform+"' ");
		sql.append(" and source1 = '" + source1+"' ");
		sql.append(" and source2 is not null ");
		sql.append(" GROUP BY source2 ");
		
		return comDao.getAllColsByVo(sql.toString(), ChinahrSource.class, DBConfig.db_131_data_bi.getIntType());
	
	}

	@Override
	public List<ChinahrSource> getSource3(String platform, String source1,
			String source2) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT * FROM data_dict.m_common_chinahr_source ");
		sql.append(" where platform = '"+platform+"' ");
		sql.append(" and source1 = '" + source1+"' ");
		sql.append(" and source2 = '" + source2+"' ");
		sql.append(" and source3 is not null ");
		sql.append(" GROUP BY source3 ");
		
		return comDao.getAllColsByVo(sql.toString(), ChinahrSource.class, DBConfig.db_131_data_bi.getIntType());
	
	}

	@Override
	public List<ChinahrSource> getSource4(String platform, String source1,
			String source2, String source3) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT * FROM data_dict.m_common_chinahr_source ");
		sql.append(" where platform = '"+platform+"' ");
		sql.append(" and source1 = '" + source1+"' ");
		sql.append(" and source2 = '" + source2+"' ");
		sql.append(" and source3 = '" + source3+"' ");
		sql.append(" and source4 is not null ");
		sql.append(" GROUP BY source4 ");
		
		return comDao.getAllColsByVo(sql.toString(), ChinahrSource.class, DBConfig.db_131_data_bi.getIntType());
	
	}
	

}
